package com.hxd.mall.module.usercenter.order

import android.content.Context
import android.graphics.Color
import android.view.animation.AccelerateInterpolator
import android.view.animation.DecelerateInterpolator
import com.alibaba.android.arouter.facade.annotation.Route
import com.hxd.mall.R
import com.hxd.mall.base.BaseInjectActivity
import com.hxd.mall.constant.HxdConstantsRouterPath.PathUserCenter.path_user_center_bindorder_order
import com.hxd.mall.constant.HxdConstantsRouterPath.PathUserCenter.path_user_center_order_query
import com.hxd.mall.module.usercenter.fragment.FragmentAdapter
import com.hxd.mall.utils.local.NavigationUtil.routerNavigation
import com.hxd.mall.utils.local.order_management_page_view
import com.hxd.mall.utils.local.sendPoint
import com.hxd.mall.utils.open.addSetOnClickListener
import com.hxd.mall.widget.TabBind
import com.hxd.mall.widget.magicIndicator.HXLinePagerIndicator
import com.hxd.mall.widget.magicIndicator.HXPagerTitleView
import crossoverone.statuslib.StatusUtil
import kotlinx.android.synthetic.main.activity_funs_manager_activity.viewPager
import kotlinx.android.synthetic.main.activity_order_query_layout.*
import net.lucode.hackware.magicindicator.ViewPagerHelper
import net.lucode.hackware.magicindicator.buildins.UIUtil
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator

/**
 * 订单管理页
 */
@Suppress("CAST_NEVER_SUCCEEDS")
@Route(path = path_user_center_order_query)
class OrderQueryActivity : BaseInjectActivity<IOrderQueryPresenter>(), IOrderQueryView {

    private lateinit var pagerIndicators: ArrayList<String>

    override fun attachLayoutRes(): Int = R.layout.activity_order_query_layout

    override fun initViews() {
        setTitleCommon(getString(R.string.order_manager))

        buildPagerIndicator()
        initViewPager()

        addSetOnClickListener(tv_bind) {
            routerNavigation(path_user_center_bindorder_order)
        }

        sendPoint(order_management_page_view)
    }

    override fun initData() {
    }

    override fun setStatusColor() {
        StatusUtil.setUseStatusBarColor(this, Color.WHITE)
    }

    override fun setSystemInvadeBlack() {
        StatusUtil.setSystemStatus(this, false, true)
    }

    private fun buildPagerIndicator() {
        pagerIndicators = arrayListOf("全部", "待结算", "已结算", "已失效")

        TabBind(magicIndicator, viewPager, pagerIndicators)
    }

    private fun initViewPager() {
        viewPager.adapter = FragmentAdapter(supportFragmentManager)
        viewPager.offscreenPageLimit = 3
        viewPager.postDelayed({ viewPager.currentItem = 1 }, 100)
        viewPager.postDelayed({ viewPager.currentItem = 0 }, 100)
    }

}
